package ar.edu.utn.frgp.controller;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import ar.edu.utn.frgp.servicio.PaqueteService;
import ar.edu.utn.frgp.servicio.ReservaService;

public class ReservasSuccesServlet extends GenericServlet {
	private ReservaService resService;
	private PaqueteService paqServise;
	
	public ReservasSuccesServlet(){
		super();
		resService = new ReservaService();
		paqServise = new PaqueteService();
	}
	
	@Override
	public void doAction(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		
		String[] cliente = request.getParameterValues("cliente");
	    String paquete = request.getParameter("paquete");
	    for(String c : cliente){	    
	    	resService.addClientet(c, paquete);
	    	paqServise.acualizarDisponibles(paquete, "-");
	    } 	
		response.sendRedirect(request.getContextPath() + "/reservasHechas");
	}	

}
